package model

import (
	"gorm.io/gorm"
	"time"
)

type Base struct {
	CreateTime time.Time `json:"create_time" grom:"column:create_time"`
	UpdateTime time.Time `json:"update_time" grom:"column:update_time"`
	DelFlag    uint      `json:"del_flag" grom:"column:del_flag"`
}

func (b *Base) BeforeCreate(tx *gorm.DB) (err error) {
	b.CreateTime = time.Now()
	b.UpdateTime = time.Now()
	b.DelFlag = 0
	return nil
}

func (b *Base) BeforeUpdate(tx *gorm.DB) (err error) {
	b.UpdateTime = time.Now()
	return nil
}
